package cn.jobstart.controller;
import cn.jobstart.common.SkList;
import cn.jobstart.dto.JobPageDTO;
import cn.jobstart.searchExt.JobSearchExt;
import cn.jobstart.vo.*;
import cn.jobstart.web.common.SkJsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RestController;
import cn.jobstart.pubInter.exception.SkException;
import cn.jobstart.pubInter.IBaseService;
import cn.jobstart.pubInter.RestfulController;
import cn.jobstart.dto.IndustryDTO;
import cn.jobstart.dto.IndustryPageDTO;
import cn.jobstart.modelExt.IndustryExt;
import cn.jobstart.searchExt.IndustrySearchExt;
import cn.jobstart.service.IIndustryService;
import cn.jobstart.export.IndustryDomainExport;
import cn.jobstart.controller.ApiManageController;
import org.springframework.validation.annotation.Validated;

import java.util.List;
import java.util.Set;
import java.util.HashSet;
import cn.jobstart.pubInter.exception.BusinessException;

/**
*    @author sunke
*    @Date 2023-09-15 15:04:57
*    @description IndustryController      行业
*/
@Api(tags = "后台管理系统-行业相关", description = "行业相关接口")
@RestController(value ="industryRestfulController")
@RequestMapping("/industry/")
@Validated
public class IndustryController extends ApiManageController<IndustryDTO,IndustryPageDTO,IndustryExt, IndustrySearchExt,IndustryDomainVO,IndustryDetailDomainVO,IndustryDetailVO,IndustryListVO,String> {

	@Resource(name = "industryService")
	private IIndustryService industryService;


	@ApiOperation(value = "顶级列表", notes = "顶级列表")
	@PostMapping(value = "topList")
	public SkJsonResult<List<IndustryDetailDomainVO>> topList(@RequestBody JobPageDTO pageDTO, HttpServletRequest request, HttpSession session) throws SkException {

		List<IndustryDetailDomainVO> topList= SkList.getInstance();
		IndustrySearchExt search=map(pageDTO,IndustrySearchExt.class);
		search.setTopFlag(1);
		return SkJsonResult.ok().setData(mapList(industryService.getAllList(search),IndustryDetailDomainVO.class));
	}
	@Override
	public IBaseService<IndustryExt, IndustrySearchExt,String> getBaseService() throws SkException {
		return industryService;
	}

	@Override
	public String getBaseRoute() {
		return "/industry/";
	}

	/**
	* 当前模板名称
	* @return
	*/
	@Override
	public String getModelName(){
		return "行业";
	}

	@Override
	public Class exportExcelClass() {
		return IndustryDomainExport.class;
	}

	@Override
	public Set<String> totalMapSet() {
		Set totalMapSet=new HashSet();
		totalMapSet.add("count(industry.i_id) as countNum");
		return totalMapSet;
	}


}